<%@ page language="java" contentType="text/html; charset=UTF-8" 
 pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="index.jsp"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8"> 
    <link href="<%=basePath%>lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>

<body>

	<!--_表格--开始-->
	<section class="Hui-article-box"  style="overflow: auto">
	    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	        <span class="c-gray en">&gt;</span>
	        商品管理
	        <span class="c-gray en">&gt;</span>
	        租赁商品管理 
	        <span class="c-gray en">&gt;</span>
	        添加商品 
	    </nav>
	
<div class="page-container">
	<form action="leaseitemadd" method="post" class="form form-horizontal" id="formadd" enctype="multipart/form-data">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">套餐名：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="套餐名不能为空" data-rule-required="true" id="combo_name" name="combo_name" onchange="checktitle()">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">品牌：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="品牌不能为空" data-rule-required="true" id="" name="brand">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">CPU：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="CPU不能为空" data-rule-required="true" id="" name="cpu">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">内存：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="内存不能为空" data-rule-required="true" id="" name="neicuen">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">显卡：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="显卡不能为空" data-rule-required="true" id="" name="xianka">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">硬盘：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="硬盘不能为空" data-rule-required="true" id="" name="yingpan">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-3">不足一个月：</label>
			<div class="formControls col-xs-2 col-sm-3">
				<input type="text" class="input-text" data-msg-required="价格不能为空"  number="true" data-msg-number="价格只能填写数字"  data-rule-required="true" id="" name="oneday">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-3">不足三个月：</label>
			<div class="formControls col-xs-2 col-sm-3">
				<input type="text" class="input-text" data-msg-required="价格不能为空"  number="true" data-msg-number="价格只能填写数字"  data-rule-required="true" id="" name="onemonth">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-3">超过三个月：</label>
			<div class="formControls col-xs-2 col-sm-3">
				<input type="text" class="input-text" data-msg-required="价格不能为空"  number="true" data-msg-number="价格只能填写数字"  data-rule-required="true" id="" name="threemonth">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">押金：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" data-msg-required="押金不能为空"  number="true" data-msg-number="价格只能填写数字"  data-rule-required="true" id="" name="yajin">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">折扣：</label>
			<div class="formControls col-xs-8 col-sm-2">
				<input type="text" class="input-text" style="display: inline-block;" placeholder="格式为: 50"  data-msg-required="折扣不能为空 "  number="true" data-msg-number="只能填写数字"  data-rule-required="true" id="" name="zheko">
			</div>
			<label>%</label>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">图片：</label>
			<div class="formControls col-xs-8 col-sm-6">
				<input type="file" id="image" name="image" value="请上传图片" /> 
			</div>
		</div>
		
		<div class="row cl" style="margin-top: 50px;margin-bottom: 100px">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i>添加商品</button>				
			</div>
		</div>
	</form>
</div>



<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script>
<script src="<%=basePath%>lib/jquery.validation/1.14.0/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
	
	//表单验证
	$(function(){
		 
		 $("#formadd").validate( {
			         //做完表单验证后的  ajax后台数据验证 如果不满足条件 则禁止表单的提交
				    submitHandler: function(form){
					//console.log(checktitle());
				     return checktitle()&&checkimage();
				     //发出ajax请求 根据回调函数的返回值 来判断checkBackitemExsit()的返回值；
				    
				    }
		 });
		 
	 });
	
	
	function checktitle() {
		var combo_name = $("#combo_name").val();
		var flag =true;
		$.ajaxSettings.async = false;
		$.post("findcname",{combo_name:combo_name},function(data){
			if(data.success){
			}else{
				layer.msg(data.msg,{icon: 2,time:2000});
				flag=false;
			}
		},"json");
		$.ajaxSettings.async = true;
		return flag;
	}
	
	
	function checkimage() {
		var img=$("#image").val();
		if(img==null||img==""){
			layer.msg("图片不能为空",{icon: 2,time:2000});
			return false;
		}else{
			return true;
		}
	}
</script>
</body>
</html>